<h1 class="inline">Edit User Command</h1>

<%= user_command_actions @user_command, :class=>"options header", :action=>'edit'%>
<hr />

<%= error_messages_for :user_command %>

<% form_for(:user_command, :url => user_command_path(@user_command), :html => { :method => :put }) do |f| %>

	<% if user_command_owner? && @user_command.command_url_changed? %>
		<div class="floatkiller" style="margin-bottom: 0px">
			<%= image_tag 'icons/cog.png' %> <i>Command Status</i>: 
			<%= url_status(@user_command) %>
		</div>
	<% end %>
	<%= render :partial => "form", :locals => {:f => f} %>
	
	<% if admin? %>
		<div class="floatkiller">
			<h3>Admin Only: Command Fields to Update</h3>
			<p style="font-size: 11px">
				When you own a command, this is used to control which fields are updated to the command	object (Defaults to all). 
				When you don't own a command, this allows you to selectively act as the command creator. For commands with options, url
				and url options	should be toggled together unless you understand why not to.
			</p>
			<% if (fields = @user_command.fields_different_than_command) && !fields.empty? %>
			<p style="font-size: 11px">
				<%= image_tag 'icons/cog.png'%>
				The following fields are different between <%= link_to 'your command', public_user_command_path(@user_command) %> and the
				 <%= link_to "queriac command", command_path(@user_command.command) %>: <%= fields.join(", ")%>.
				You should compare the two before overwriting these fields.
			</p>
			<% end %>
			
			<%= link_to_function "Check All", "check_all_for_selector('.command_fields')", :class=>'function_link'%> |
			<%= link_to_function "Uncheck All", "uncheck_all_for_selector('.command_fields')", :class=>'function_link'%><br/>
			<% checkbox_state = @user_command.command_owned_by?(current_user)%>
			<% UserCommand::COMMAND_UPDATE_FIELDS.each do |c| %>
				<% id = "command_field_#{c}"%>
				<%= check_box_tag "command_fields[]", c, checkbox_state, :id=>id, :class=>'command_fields' %>
				<%= label_tag id, c %>
			<% end %>
		</div>
	<% end %>

  <div class="floatkiller">
    <%= submit_tag "Save Changes", :class => "submit" %>
  </div>
<% end %>